#include <iostream>

using namespace std;

typedef long long LL;

const int N = 5e6 + 10;
const LL MOD = 998244353;

LL f[N];
LL g[N];

LL qpow(LL a, LL b, LL p)
{
	LL ret = 1;
	while(b)
	{
		if(b & 1) ret = (ret * a) % p;
		b >>= 1;
		a = (a * a) % p;
	}
	return ret;
}

int main()
{
	int T, n;
	scanf("%d%d", &T, &n);
	f[0] = 1;
	for(int i = 1; i <= n; i++) f[i] = (f[i - 1] * i) % MOD;
	
	g[n] = qpow(f[n], MOD - 2, MOD);
	
	for(int i = n - 1; i >= 0; i--) g[i] = (g[i + 1] * (i + 1)) % MOD;
	LL ans = 0;
	while(T--)
	{
		int x, y; scanf("%d%d", &x, &y);
		// x! / y! x - y!
		LL ret = ((f[x] * g[y]) % MOD * g[x - y]) % MOD;
		ans ^= ret;
	}
	printf("%lld\n", ans);
	return 0;
}



 
